﻿using ezCloud.Api.Models;
using ezCloud.Data;
using Microsoft.AspNet.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Web.Http.ModelBinding;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OAuth;

using ezCloud.Api.Providers;
using ezCloud.Api.Results;
using System.Data.SqlTypes;
using ezCloud.Api.Common;




namespace ezCloud.Api.Controllers
{
    [RoutePrefix("api/Error")]
    public class ErrorController : ezController
    {
        private ApplicationUserManager _userManager;

        public ApplicationUserManager UserManager
        {
            get
            {
                return _userManager ?? Request.GetOwinContext().GetUserManager<ApplicationUserManager>();
            }
            private set
            {
                _userManager = value;
            }
        }
       
       
       [Route("Insert")]
       public async Task<IHttpActionResult> PostAppError(ErrorMesssage error)
       {
            error.date = DateTime.UtcNow;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            Common.Elastic.IndexErrorLog(error);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            return Ok();
       }
    }
    public class ErrorMesssage
    {
        public string exception { get; set; }
        public string cause { get; set; }
        public DateTime date { get; set; }
    }
}